Skip to content

feat(pdo): add fetch-object statement wrapper#25

Merged
Chemaclass merged 1 commit into
mainfrom
feat/11-fetch-object
Jun 3, 2026
Merged

feat(pdo): add fetch-object statement wrapper#25
Chemaclass merged 1 commit into
mainfrom
feat/11-fetch-object

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Wraps PDOStatement::fetchObject as pdo/fetch-object: (fetch-object stmt & [class-name ctor-args]). Returns the next row as an object - stdClass by default, or an instance of class-name (with optional constructor args) - and nil when the result set is exhausted.

Return-shape decision (per #11)

Converting to a map would make this identical to fetch, adding nothing. The wrapper's value is hydrating rows into a named class, so it returns the PHP object as PDO produces it. The default stdClass path is kept for callers who prefer object access. false (no row) is normalised to nil, matching fetch.

  • Removed from the "Not implemented yet" block in src/pdo/statement.phel.
  • Tests: fetch-object-returns-stdclass-row (class + property) and fetch-object-returns-nil-when-no-rows.
  • README API table + CHANGELOG ## [Unreleased] updated.

Polish pass: no refactor needed - when-let mirrors the nil-guard idiom already used by fetch.

composer test green (38 assertions).

Closes #11

@Chemaclass Chemaclass added the enhancement New feature or request label Jun 3, 2026
@Chemaclass Chemaclass self-assigned this Jun 3, 2026
@Chemaclass Chemaclass merged commit 25a080a into main Jun 3, 2026
1 check passed
@Chemaclass Chemaclass deleted the feat/11-fetch-object branch June 3, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement statement/fetch-object wrapper for PDOStatement::fetchObject

1 participant